<include file="public@header"/>

<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('CourseSchedule/adjustSchedule')}">调课列表</a></li>
        <li><a href="{:url('CourseSchedule/add')}">添加</a></li>
    </ul>
    <form class="well form-inline margin-top-20 row" method="post" action="{:url('CourseSchedule/adjustSchedule')}">
        <label class="form-group col-lg-5 col-md-6" >
            校区-班级:
            <select class="form-control" name="school_id" id="school_id" style="width:179px;">
                <option value='0'>全部</option>
                <notempty name="school">
                    <volist name="school" id="vo">
                        <if condition="isset($param.school_id) && $param.school_id == $vo.id">
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                        <else/>
                            <option value="{$vo.id}">{$vo.name}</option>
                        </if>
                    </volist>
                </notempty>
            </select> -
            <select class="form-control" name="class_id" id="class_id" style="width:179px;">
                <option value='0'>全部</option>
                <notempty name="classes">
                    <volist name="classes" id="vo">
                        <if condition="isset($param.class_id) && $param.class_id == $vo.id">
                            <option value="{$vo.id}" selected>{$vo.name}</option>
                            <else/>
                            <option value="{$vo.id}">{$vo.name}</option>
                        </if>
                    </volist>
                </notempty>
            </select>
        </label>

        <label class="form-group col-lg-4 col-md-3" >
            课程:
            <select class="form-control" name="course_id" id="course_id" >
                <option value='0'>全部</option>
                <notempty name="course">
                    <volist name="course" id="vo">
                        <if condition="isset($param.course_id) && $param.course_id == $vo.id">
                            <option value="{$vo.id}" selected>{$vo.course_name}</option>
                            <else/>
                            <option value="{$vo.id}">{$vo.course_name}</option>
                        </if>
                    </volist>
                </notempty>
            </select>
        </label>


        <label class="form-group col-lg-3 col-md-3">
             <input type="submit" class="btn btn-primary" value="搜索"/>
            <a class="btn btn-danger" href="{:url('CourseSchedule/adjustSchedule')}">清空</a>
        </label>
    </form>

    <form class="js-ajax-form" action="" method="post">
        <div class="table-actions">
            <button class="btn btn-danger btn-sm js-ajax-submit" type="submit"
                    data-action="{:url('CourseSchedule/delete')}" data-subcheck="true" data-msg="您确定删除吗？">批量删除
            </button>
        </div>
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="15">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th>编号</th>
                <th>学校</th>
                <th>班级</th>
                <th>课程</th>
                <th>开始日期</th>
                <th>结束日期</th>
                <th>操作</th>
            </tr>
            </thead>
            <notempty name="adjust">
                <foreach name="adjust" item="vo">
                    <tr>
                        <td>
                            <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                                   value="{$vo.id}" title="ID:{$vo.id}">
                        </td>
                        <td>{$vo.id}</td>
                        <td>{$vo.school_name}</td>
                        <td>{$vo.class_name}</td>
                        <td>{$vo.course_name}</td>
                        <td>{$vo.start_date|date="Y-m-d",###}</td>
                        <td>{$vo.end_date|date="Y-m-d",###}</td>
                        <td><a href="{:url('CourseSchedule/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">{:lang('DELETE')}</a></td>
                    </tr>
                </foreach>
            </notempty>
        </table>
        <div class="pagination">{$page|default=''}</div>
    </form>
</div>

<script src="__STATIC__/js/admin.js"></script>
<script>

    $(document).ready(function () {
        $('#school_id').on('change',function () {
            var sid = $(this).val();
            if(sid == 0){
                $('#class_id').empty();
                var html = '<option value=\"0\">全部</option>';
                $('#class_id').html(html);
                return false;
            }
            $.ajax({
                url:"{:url('CourseSchedule/ajax_class')}",
                type:'post',
                dataType:'json',
                data:{"school_id":sid},
                success:function(jsonData){
                    $('#class_id').empty();
                    var html = '<option value=\"0\">全部</option>';

                    if(jsonData.code == 1){
                        for(var i in jsonData.data){
                            html += '<option value=\"'+jsonData.data[i].id+'\">'+jsonData.data[i].name+'</option>';
                        }
                    }
                    $('#class_id').html(html);
                },
                error:function(XMLHttpRequest, textStatus, errorThrown){
                    console.log('xhr='+XMLHttpRequest.readyState+' status='+textStatus+' error='+errorThrown);
                }
            });
        });

        $('input[name="start"]').datepicker();
        $('input[name="end"]').datepicker();
    });

</script>
</body>